package com.zhouhong;

import java.util.Random;

/**
 * @ClassName: LinearSearch
 * @Description: 生成乱序数组工具类
 * @Author: zhouhong
 * @Create: 2021-03-28 16:25
 **/

public class ArrayGenerator {

    private ArrayGenerator(){}
    // 生成完全有序的数组
    public static Integer[] generatorOrderedArray(int n){
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i] = i;
        }
        return arr;
    }
    // 生成长度为 n 的随机数组，每个数字的长度为[0, bound)
    public static Integer[] generatorRandomArray(int n, int bound){
        Integer[] arr = new Integer[n];

        Random rnd = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = rnd.nextInt(bound);
        }
        return arr;
    }
}
